using System;
using ShadeTree.Binding.Configuration;

namespace ShadeTree.Binding.Elements
{
    public class TextEditingElementExpression : ScreenElementExpression<TextEditingElementExpression>
    {
        private const string PRECISION_FORMAT_PATTERN = "{{0:F{0}}}";
        private ITextEditingElement _element;

        public TextEditingElementExpression(ITextEditingElement element)
            : base(element)
        {
            _element = element;
        }

        protected override TextEditingElementExpression thisExpression()
        {
            return this;
        }

        public TextEditingElementExpression ThePrecisionIs(int numDigitsAfterDecimal)
        {
            _element.Format = o => String.Format(String.Format(PRECISION_FORMAT_PATTERN, numDigitsAfterDecimal), o);
            return this;
        }
    }
}